# -*-coding:utf-8-*-

from __future__ import print_function
import keras.backend as K
from keras.layers.merge import concatenate
from keras.layers.normalization import BatchNormalization
from keras.layers import Bidirectional, TimeDistributed, Conv2D, MaxPooling2D, Input, GRU, Dense, Activation, Dropout, Reshape, Permute, GlobalAveragePooling2D
K.set_image_data_format('channels_first')
if K.image_data_format() == 'channels_first':
    CHANNEL_AXIS = 1
else:
    CHANNEL_AXIS = -1
CURRENT_VERBOSITY = 0


def conv2d_bn(x, filters, kernel, strides=1, padding='same'):
    x = Conv2D(filters=filters, kernel_size=(kernel[0], kernel[1]), strides=strides, padding='same')(x)
    x = BatchNormalization(axis=1)(x)
    x = Activation('relu')(x)
    return x


def inception_block(x):
    branch_0 = conv2d_bn(x, filters=32, kernel=[1, 1])

    branch_1 = conv2d_bn(x, filters=32, kernel=[1, 1])
    branch_1 = conv2d_bn(branch_1, filters=32, kernel=[1, 1])

    branch_2 = conv2d_bn(x, filters=32, kernel=[1, 1])
    branch_2 = conv2d_bn(branch_2, filters=32, kernel=[1, 1])
    branch_2 = conv2d_bn(branch_2, filters=32, kernel=[1, 1])

    branch_3 = MaxPooling2D(pool_size=(3, 3), strides=(1, 1), padding='same')(x)   # 不降维池化
    branch_3 = conv2d_bn(branch_3, filters=32, kernel=[1, 1])

    output = concatenate([branch_0, branch_1, branch_2, branch_3], axis=CHANNEL_AXIS)

    return output
